<?php

require './configs/config.php';
require './models/DB.class.php';

//实现自动加载
function mvc_autoload($classname){
    // echo $classname;
    if(file_exists("./models/{$classname}.class.php")){
        require "./models/{$calssname}.class.php";
    }elseif(file_exists("./controllers/{$classname}.php")){
        require "./controllers/{$classname}.php";
    }else{
        // header('HTTP/1.0 404 not found');
        echo '<h1>404 NOT  FOUND</h1>';
        exit;
    }
}

//导入smarty模板引擎
require './libs/Smarty.class.php';
//注释给定的函数作为 __autoload  的实现
spl_autoload_register('mvc_autoload');
// $smarty = new Smarty();



//获取用户参数
//获取控制器名
$c = (!empty($_GET['c']))?$_GET['c']:'Index';
$a = (!empty($_GET['a']))?$_GET['a']:'index';

//拼接类名
$classname = $c . 'Controller';
//实例化 类名
$controller = new $classname();
//调用方法
$controller->$a();


